<script>
  import {
    mapState,
    mapMutations,
    mapGetters
  } from 'vuex';

  export default {
    computed: {
      ...mapState({
        hasRegister: state => state.user.hasRegister,
        hasLogin: state => state.user.hasLogin,
        hasPhone: state => state.user.hasPhone,
      }),
    },
    onLaunch: function(opt) {
      this.userLogin();
    },
    onShow: function(opt) {
      // console.log("App onShow:", opt);
    },
    onHide: function() {
      // console.log('App Hide');
    },
    methods: {
      userLogin() {
        this.$store.dispatch('user/login')
        .then(res => {
          // console.log("[app]user-login:", res);
          let remoteSession = res.module;
          const { phone, register } = remoteSession;
          if (!register || !phone) {
            this.$store.dispatch('user/getAndSaveUser')
          }
        })
      }
    }
  }
</script>

<style lang="scss">
	/*每个页面公共css */
  @import "@/styles/index.scss";
</style>
